package com.sjksy.demo.mapper;

import com.sjksy.demo.domain.Employee;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sjksy.demo.dto.employee.EmployeeDto;
import com.sjksy.demo.vo.employee.EmployeeRequestVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* @author guyueyuan
* @description 针对表【employee】的数据库操作Mapper
* @createDate 2024-12-11 15:37:02
* @Entity com.sjksy.demo.domain.Employee
*/
@Repository
@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {
    /**
     * 插入经理信息
     * @param employeeRequestVo
     */
    @Insert("insert into employee (name, id_card_number, branch_id, emp_ty_id) " +
            "VALUES (#{name},#{idCardNumber},#{branchId},#{empTyId}) ")
    @Options(useGeneratedKeys = true,keyProperty = "employeeId")
    void insert(EmployeeRequestVo employeeRequestVo);

    /**
     * 删除员工信息
     * @param id
     */
    @Delete("delete from employee where employee_id=#{id}")
    void delete(Integer id);

    @Select("select * from employee")
    List<Employee> getAll();

    @Select("select e.name,e.id_card_number,b.branch_name from employee e,branch b where" +
            " e.employee_id=#{employeeId} and e.branch_id=b.branch_id")
    EmployeeDto getGuide(Integer employeeId);
}




